//
//  WebBaseViewController.m
//  BProject
//
//  Created by 久远的回忆 on 15/8/11.
//  Copyright (c) 2015年 久远的回忆. All rights reserved.
//

#import "WebBaseViewController.h"
#import "UMSocial.h"

@interface WebBaseViewController ()<UIWebViewDelegate>

@property (nonatomic,assign) CGFloat webViewHeight;
@end

@implementation WebBaseViewController

- (void)creatBar
{

    UIView * view = [UIView UIViewWithFrame:CGRectMake(0, SCREEN_HEIGHT - 70, SCREEN_WIDTH, 70)];
    [self.view addSubview:view];
    self.toTopButton = [UIButton buttonWithType1:UIButtonTypeCustom];
    self.toTopButton.frame = CGRectMake(SCREEN_WIDTH - 140, 15, 40, 40);
    [self.toTopButton addTarget:self action:@selector(topAction) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:self.toTopButton];
    
    self.toBomButton = [UIButton buttonWithType1:UIButtonTypeCustom];
    self.toBomButton.frame = CGRectMake(SCREEN_WIDTH - 50, 15, 40, 40);
    [self.toBomButton addTarget:self action:@selector(bomAction) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:self.toBomButton];
    
    UIButton *shareButton = [UIButton buttonWithType1:UIButtonTypeCustom];
    shareButton.frame = CGRectMake(SCREEN_WIDTH - 230, 15, 40, 40);
    [shareButton setImage:[UIImage imageNamed:@"iconfont-fenxiang.png"] forState:UIControlStateNormal];
    [shareButton addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:shareButton];
    
    
    
    _button = [UIButton buttonWithType1:UIButtonTypeCustom];
    _button.frame = CGRectMake(15, 15, 40, 40);
    [_button addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:_button];
    
    
    [_button setImage:[UIImage imageNamed:@"iconfont-fanhuijian.png"] forState:UIControlStateNormal];
    [self.toTopButton setImage:[UIImage imageNamed:@"iconfont-fanhuidingbu.png"] forState:UIControlStateNormal];
    [self.toBomButton setImage:[UIImage imageNamed:@"iconfont-yidaodibu.png"] forState:UIControlStateNormal];
    
    
//    NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
//    for (int i = 1; i <=2; i++) {
//        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.tiff",i]];
//        [array addObject:image];
//    }
//    _myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 70)];
//    //_myImageView.contentMode = UIViewContentModeCenter;
//    _myImageView.animationImages = array;//添加动态图所要的图片们
//    _myImageView.animationDuration = 0.2;//多长时间内完成一个动画播放;
//    _myImageView.backgroundColor= [UIColor clearColor];
//    _myImageView.alpha = 0.3;
//    [_myImageView startAnimating];//开始播放动画;
//    [self.view addSubview:_myImageView];
    
    
    
}
- (void)tapAction:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)topAction
{
    self.webView.scrollView.contentOffset = CGPointMake(0, 0);
}

- (void)bomAction
{
    self.webView.scrollView.contentOffset = CGPointMake(0, _webViewHeight - SCREEN_HEIGHT + 70);
}


- (void)share:(UIButton *)button
{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"55dc33e9e0f55afe490079f9"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina, UMShareToTencent, UMShareToRenren, UMShareToDouban, UMShareToEmail, UMShareToSms, nil]
                                       delegate:nil];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    //self.view.backgroundColor = [UIColor whiteColor];
    [self creatBar];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    _webViewHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"] floatValue];
//    [self.myImageView removeFromSuperview];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
